import { request } from '@/utils/request'
import type { GoodsQuery, Goods } from '@/types/goods'

// 分页获取商品列表
export const getGoodsList = (data: GoodsQuery) => {
  return request<{ total: number; items: Goods[] }>({
    url: 'pro/list',
    data
  })
}

// 获取商品分类
export const getCategories = () => {
  return request<string[]>({
    url: 'pro/getCategory'
  })
}

// 更改是否售卖、是否秒杀、是否推荐的状态
export const updateFlag = (data: {
  proid: string
  state: 0 | 1
  type: 'issale' | 'isseckill' | 'isrecommend'
}) => {
  return request({
    url: 'pro/updateFlag',
    method: 'POST',
    data
  })
}
